package com.h3c.nem.controller;

import com.eos.common.constant.StatusCodeEnum;
import com.eos.common.util.Result;
import com.h3c.nem.dto.TbOfferPatentInfoDTO;
import com.h3c.nem.service.ITbOfferPatentService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * 专利信息控制层
 *
 * @author chenyifan
 * @since 2022-06-06 16:34:44
 */
@CrossOrigin
@RestController
@AllArgsConstructor
@RequestMapping("/tbOfferPatent")
public class TbOfferPatentController {
    /**
     * 服务对象
     */
    private final ITbOfferPatentService tbOfferPatentService;

    /**
     * 保存专利信息和专业技术成果信息
     * @return
     */
    @PostMapping("/saveOfferPatentInfo")
    public Result<String> saveOfferPatentInfo(@RequestBody TbOfferPatentInfoDTO patentInfoDTO){
        try {
            tbOfferPatentService.saveOfferPatentInfo(patentInfoDTO);
            return new Result(true, StatusCodeEnum.NORMAL);
        } catch (Exception e) {
            return new Result(false, StatusCodeEnum.ADD_FAIl);
        }
    }

    /**
     * 回显专利信息
     * @return
     */
    @GetMapping("/showOfferPatentInfo")
    public Result<String> showOfferPatentInfo(){
        try {
            return new Result(true, StatusCodeEnum.NORMAL,tbOfferPatentService.showOfferPatentInfo());
        } catch (Exception e) {
            return new Result(false, StatusCodeEnum.ADD_FAIl);
        }
    }
}

